package tuan.filter;

import org.w3c.dom.Node;

import tuan.utils.RegUtil;
import tuan.utils.StringUtil;

public class MatchFiltter extends NodeFilter {

	public String pattern;

	public MatchFiltter(String pattern) throws Exception {
		if (pattern == null) {
			throw new Exception("null arguments");
		}
		if (pattern == null) {
			throw new Exception("null arguments");
		}
		this.pattern = pattern;
	}

	@Override
	protected boolean isValid(Node node) throws Exception {
		return RegUtil.match(pattern, StringUtil.getPureText(node.getTextContent()));
	}

}